﻿using System;
using System.Globalization;
using System.Linq;
using System.Web.UI;
using BlueMarineWebClient.DO;

namespace BlueMarineWebClient.Admin
{
    public partial class Report : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false || Request.QueryString["view"] == "today")
            {
                txtDate.Text = DateTime.Today.ToString("dd/MM/yyyy");
                BindGrid(DateTime.Today);
            }
        }

        private void BindGrid(DateTime date)
        {
            gvReportCheckIn.DataSource =
                ServiceBool.ExService.SelectTotalCheck(date, 0).OrderByDescending(p => p.CheckInDate);
            gvReportCheckIn.DataBind();
            gvReportCheckOut.DataSource =
                ServiceBool.ExService.SelectTotalCheck(date, 1).OrderByDescending(p => p.CheckOutDate);
            gvReportCheckOut.DataBind();
        }


        protected void btnView_Click(object sender, EventArgs e)
        {
            BindGrid(DateTime.ParseExact(txtDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture));
        }
    }
}